#include <bits/stdc++.h>

using namespace std;

#define N 1005

int Hash[N] = {0};

struct queue{
    int data[N];
    int front;
    int rear;

    bool init(){
        front = rear = 0;
        return true;
    }

    int size(){
        return (rear - front + N) % N;
    }

    bool push(int e){
        if ((rear + 1) % N == front){
            return false;
        }
        data[rear] = e;
        rear = (rear + 1) % N;
        return true;
    }

    bool pop(int &e){
        if (front == rear){
            return false;
        }
        e = data[front];
        front = (front + 1) % N;
        return true;
    }
}Q;

int main(){
    Q.init();
    int m, n;
    cin >> m >> n;
    int cnt;

    while (n--){
        int en;
        cin >> en;

        if (!Hash[en]){
            ++cnt;
            Hash[en] = 1;
            Q.push(en);
            if (Q.size() > m){
                int tmp; 
                Q.pop(tmp);
                Hash[tmp] = 0;
            }
        }
    }
    cout << cnt;
    
    return 0;
}